home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / MCASTU.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  9KB  |  353 lines

  1. /*    SCCS Id: @(#)mcastu.c    3.0    88/04/13
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include    "hack.h"
  6.  
  7. #ifdef OVL0
  8.  
  9. static void FDECL(cursetxt,(struct monst *));
  10. const char *spelltyp[] = {
  11.     "shower of missiles",
  12.     "fireball",
  13.     "sleep ray",
  14.     "cone of cold",
  15.     "finger of death",
  16.     "bolt of lightning",
  17.     "",
  18.     "",
  19.     "",
  20.     ""
  21. };
  22.  
  23. static
  24. void
  25. cursetxt(mtmp)
  26.     register struct monst *mtmp;
  27. {
  28.     if(canseemon(mtmp)) {
  29.         if ((Invis && !perceives(mtmp->data) &&
  30.                 (mtmp->mux != u.ux || mtmp->muy != u.uy))
  31. #ifdef POLYSELF
  32.             || u.usym == S_MIMIC_DEF || u.uundetected
  33. #endif
  34.                                     )
  35.         pline("%s points and curses in your general direction.",
  36.                 Monnam(mtmp));
  37.         else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy))
  38.         pline("%s points and curses at your displaced image.",
  39.                 Monnam(mtmp));
  40.         else
  41.         pline("%s points at you, then curses.", Monnam(mtmp));
  42.     } else if((!(moves%4) || !rn2(4)) && flags.soundok) 
  43.         You("hear a mumbled curse.");
  44. }
  45.  
  46. #endif /* OVL0 */
  47. #ifdef OVLB
  48.  
  49. int
  50. castmu(mtmp, mattk)    /* monster casts spell at you */
  51.     register struct monst *mtmp;
  52.     register struct attack *mattk;
  53. {
  54.     int    dmg = 0, ml = mtmp->m_lev;
  55.  
  56.     if(mtmp->mcan || mtmp->mspec_used || !ml) {  /* could not attack */
  57.         cursetxt(mtmp);
  58.         return(0);
  59.     } else {
  60.         nomul(0);
  61.         if(rn2(ml*10) < (mtmp->mconf ? 100 : 20)) {    /* fumbled attack */
  62.         if(canseemon(mtmp)
  63. #ifdef SOUNDS
  64.                 && flags.soundok
  65. #endif
  66.                             )
  67.             pline("The air crackles around %s.", mon_nam(mtmp));
  68.         return(0);
  69.         }
  70.     }
  71. /*
  72.  *    As these are spells, the damage is related to the level
  73.  *    of the monster casting the spell.
  74.  */
  75.     if (mattk->damd)
  76.         dmg = d((int)((ml/3) + mattk->damn), (int)mattk->damd);
  77.     else dmg = d((int)((ml/3) + 1), 6);
  78.  
  79.     switch(mattk->adtyp)   {
  80.  
  81.         case AD_FIRE:
  82.         pline("You're enveloped in flames.");
  83.         if(Fire_resistance) {
  84.             shieldeff(u.ux, u.uy);
  85.             pline("But you resist the effects.");
  86.             dmg = 0;
  87.         }
  88.         break;
  89.         case AD_COLD:
  90.         pline("You're covered in frost.");
  91.         if(Cold_resistance) {
  92.             shieldeff(u.ux, u.uy);
  93.             pline("But you resist the effects.");
  94.             dmg = 0;
  95.         }
  96.         break;
  97. #ifdef INFERNO
  98.         case AD_MAGM:
  99.         You("are hit by a shower of missiles!");
  100.         if(Antimagic) {
  101.             shieldeff(u.ux, u.uy);
  102.             pline("The missiles bounce off!");
  103.             dmg = 0;
  104.         } else dmg = d((int)mtmp->m_lev/2 + 1,6);
  105.         break;
  106. #endif
  107.         case AD_SPEL:    /* random spell */
  108.  
  109.         mtmp->mspec_used = 10 - mtmp->m_lev;
  110.         if (mtmp->mspec_used < 2) mtmp->mspec_used = 2;
  111.         switch(rn2((int)mtmp->m_lev)) {
  112.             case 22:
  113.             case 21:
  114.             case 20:
  115.             pline("Oh no, %s's using the touch of death!",
  116.                   is_female(mtmp) ? "she" :
  117.                   is_human(mtmp->data) ? "he" : "it"
  118.                  );
  119. #ifdef POLYSELF
  120.             if (is_undead(uasmon))
  121.                 You("seem no deader than before.");
  122.             else
  123. #endif
  124.             if(!Antimagic && rn2(ml) > 12)  {
  125.  
  126.                 if(Hallucination)
  127.                 You("have an out of body experience.");
  128.                 else  {
  129.                 killer_format = KILLED_BY_AN;
  130.                 killer = "touch of death";
  131.                 done(DIED);
  132.                 }
  133.             } else {
  134.                 if(Antimagic) shieldeff(u.ux, u.uy);
  135.                 pline("Lucky for you, it didn't work!");
  136.             }
  137.             dmg = 0;
  138.             break;
  139.             case 19:
  140.             case 18:
  141.             if(mtmp->iswiz && flags.no_of_wizards == 1) {
  142.                 pline("Double Trouble...");
  143.                 clonewiz();
  144.                 dmg = 0;
  145.                 break;
  146.             } /* else fall into the next case */
  147.             case 17:
  148.             case 16:
  149.             case 15:
  150.             if(mtmp->iswiz && flags.soundok)
  151.                 pline("\"Destroy the thief, my pets!\"");
  152. #ifdef HARD
  153.             nasty();    /* summon something nasty */
  154. #endif
  155.             /* fall into the next case */
  156.             case 14:        /* aggravate all monsters */
  157.             case 13:
  158.             aggravate();
  159.             dmg = 0;
  160.             break;
  161.             case 12:        /* curse random items */
  162.             case 11:
  163.             case 10:
  164.             rndcurse();
  165.             dmg = 0;
  166.             break;
  167.             case 9:
  168.             case 8:        /* destroy armor */
  169.             if(Antimagic) {
  170.                 shieldeff(u.ux, u.uy);
  171.                 pline("A field of force surrounds you!");
  172.             } else if(!destroy_arm(some_armor()))
  173.                 Your("skin itches.");
  174.             dmg = 0;
  175.             break;
  176.             case 7:
  177.             case 6:        /* drain strength */
  178.             if(Antimagic) {
  179.                 shieldeff(u.ux, u.uy);
  180.                 You("feel momentarily weakened.");
  181.             } else {
  182.                 You("suddenly feel weaker!");
  183.                 losestr(rnd(ml - 6));
  184.                 if(u.uhp < 1)
  185.                 done_in_by(mtmp);
  186.             }
  187.             dmg = 0;
  188.             break;
  189.             case 5:        /* make invisible if not */
  190.             case 4:
  191.             if(!mtmp->minvis) {
  192.                 if(canseemon(mtmp) && !See_invisible)
  193.                 pline("%s suddenly disappears!",
  194.                       Monnam(mtmp));
  195.                 mtmp->minvis = 1;
  196.                 unpmon(mtmp);
  197.                 dmg = 0;
  198.                 break;
  199.             } /* else fall into the next case */
  200.             case 3:        /* stun */
  201.             if(Antimagic) {
  202.                 shieldeff(u.ux, u.uy);
  203.                 if(!Stunned)
  204.                 You("feel momentarily disoriented.");
  205.                 make_stunned(1L, FALSE);
  206.             } else {
  207.                 if (Stunned)    You("struggle to keep your balance.");
  208.                 else        You("reel...");
  209.                 make_stunned(HStun + d(ACURR(A_DEX) < 12 ? 6 : 4, 4), FALSE);
  210.             }
  211.             dmg = 0;
  212.             break;
  213.             case 2:        /* haste self */
  214.             if(mtmp->mspeed == MSLOW)    mtmp->mspeed = 0;
  215.             else                mtmp->mspeed = MFAST;
  216.             dmg = 0;
  217.             break;
  218.             case 1:        /* cure self */
  219.             if(mtmp->mhp < mtmp->mhpmax) {
  220.                 if((mtmp->mhp += rnd(8)) > mtmp->mhpmax)
  221.                 mtmp->mhp = mtmp->mhpmax;
  222.                 dmg = 0;
  223.                 break;
  224.             } /* else fall through to default case */
  225.             default:        /* psi bolt */
  226.             if(Antimagic) {
  227.                 shieldeff(u.ux, u.uy);
  228.                 You("get a slight %sache.",body_part(HEAD));
  229.                 dmg = 1;
  230.             } else {
  231.                 if (dmg <= 10)
  232.                 Your("brain is on fire!");
  233.                 else Your("%s suddenly aches!", body_part(HEAD));
  234.             }
  235.             break;
  236.         }
  237.         break;
  238.         
  239.         case AD_CLRC:    /* clerical spell */
  240.  
  241.         mtmp->mspec_used = 10 - mtmp->m_lev;
  242.         if (mtmp->mspec_used < 2) mtmp->mspec_used = 2;
  243.         switch(rn2((int)mtmp->m_lev)) {
  244.             /* Other ideas: lightning bolts, towers of flame,
  245.                     gush of water  -3. */
  246.  
  247.             default:        /* confuse */
  248.             if(Antimagic) {
  249.                 shieldeff(u.ux, u.uy);
  250.                 You("feel momentarily dizzy.");
  251.             } else {
  252.                 make_confused(HConfusion + (long)mtmp->m_lev, TRUE);
  253.             }
  254.             dmg = 0;
  255.             break;
  256.             case 12:        /* curse random items */
  257.             case 11:
  258.             case 10:
  259.             rndcurse();
  260.             dmg = 0;
  261.             break;
  262.             case 9:
  263.             case 8:        /* insects */
  264.             /* Try for insects, and if there are none
  265.                left, go for (sticks to) snakes.  -3. */
  266.             {
  267.             int i;
  268.             struct permonst *pm = mkclass(S_ANT);
  269.             struct monst *mtmp2;
  270.             char let = (pm ? S_ANT : S_SNAKE);
  271.   
  272.             for (i = 0; i <= mtmp->m_lev; i++)
  273.                if ((pm = mkclass(let)) &&
  274.                     (mtmp2 = makemon(pm, u.ux, u.uy)))
  275.                 mtmp2->msleep = mtmp2->mpeaceful =
  276.                     mtmp2->mtame = 0;
  277.             }            
  278.             dmg = 0;
  279.             break;
  280.             case 6:
  281.             case 7:        /* blindness */
  282.             if (!Blinded) {
  283.                 pline("Scales cover your eyes!");
  284.                 make_blinded(200L, FALSE);
  285.                 dmg = 0;
  286.                 break;
  287.             }
  288.             case 4:
  289.             case 5:        /* wound */
  290.             if(Antimagic) {
  291.                 shieldeff(u.ux, u.uy);
  292.                 Your("skin itches badly for a moment.");
  293.                 dmg = 0;
  294.             } else {
  295.                 pline("Wounds appear on your body!");
  296.                 dmg = d(2,8) + 1;
  297.             }
  298.             break;
  299.             case 3:        /* hold */
  300.             if(Antimagic) {
  301.                 shieldeff(u.ux, u.uy);
  302.                 if(multi >= 0)
  303.                 You("stiffen briefly.");
  304.                 nomul(-1);
  305.              } else {
  306.                 if (multi >= 0)    
  307.                     You("are frozen in place!");
  308.                 nomul(-4 - (int)mtmp->m_lev);
  309.             }
  310.             dmg = 0;
  311.             break;
  312.             case 2:
  313.             case 1:        /* cure self */
  314.             if(mtmp->mhp < mtmp->mhpmax) {
  315.                 if((mtmp->mhp += rnd(8)) > mtmp->mhpmax)
  316.                 mtmp->mhp = mtmp->mhpmax;
  317.                 dmg = 0;
  318.                 break;
  319.             } /* else fall through to default case */
  320.         }
  321.     }
  322.     if(dmg) mdamageu(mtmp, dmg);
  323.     return(1);
  324. }
  325.  
  326. #endif /* OVLB */
  327. #ifdef OVL0
  328.  
  329. int
  330. buzzmu(mtmp, mattk)        /* monster uses spell (ranged) */
  331.     register struct monst *mtmp;
  332.     register struct attack  *mattk;
  333. {
  334.     if(mtmp->mcan || mattk->adtyp > AD_SPC2) {
  335.         cursetxt(mtmp);
  336.         return(0);
  337.     }
  338.     if(lined_up(mtmp) && rn2(3)) {
  339.         nomul(0);
  340.         if(mattk->adtyp && (mattk->adtyp < 11)) { /* no cf unsigned >0 */
  341.         if(canseemon(mtmp))
  342.             pline("%s zaps you with a %s!", Monnam(mtmp),
  343.               spelltyp[mattk->adtyp-1]);
  344.         buzz((int) (-10 - (mattk->adtyp-1)), (int)mattk->damn,
  345.              mtmp->mx, mtmp->my, sgn(tbx), sgn(tby));
  346.         } else impossible("Monster spell %d cast", mattk->adtyp-1);
  347.     }
  348.     return(1);
  349. }
  350.  
  351. #endif /* OVL0 */
  352.  
  353.